Runs a SQL command on a data source linked to an external datasheet and returns the number of rows the command is performed on. You can use the return value with other statements to validate the number of records affected by the command.
Syntax
RunSQLCommand("DatasheetName", "SQLCommand", FailureBehavior)
Arguments
Argument | Description |
---|---|
DatasheetName | External datasheet name. Must be in the current workspace and linked to a data source. |
SQLCommand | SQL command to run. |
FailureBehavior | Failure behavior. True stops the script if the command fails. False displays a warning and continues playback. |
Return value
Value | Description |
---|---|
Value | Number of rows updated, inserted, or deleted in the data source. |
0 | Command other than UPDATE, INSERT, or DELETE ran against an Excel, Access, or text file data source. |
-1 | Command other than UPDATE, INSERT, or DELETE ran against an Oracle or SQL Server data source. |
Null | Command failed. |
Example
rowsAffected = RunSQLCommand("CustomerRecordsDatasheet", "UPDATE CustomerRecords SET Purchased=True WHERE FirstName='John' AND LastName='Smith'", True)
PrintLn("Rows updated: " + rowsAffected)